package com.tea.funct.service.impl;

import com.tea.common.utils.DateUtils;
import com.tea.funct.domain.TeaCategory;
import com.tea.funct.mapper.TeaCategoryMapper;
import com.tea.funct.service.ITeaCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 产品大类Service业务层处理
 *
 * @author Sophia
 * @date 2024-05-25
 */
@Service
public class TeaCategoryServiceImpl implements ITeaCategoryService {
    @Autowired
    private TeaCategoryMapper teaCategoryMapper;

    /**
     * 查询产品大类
     *
     * @param id 产品大类主键
     * @return 产品大类
     */
    @Override
    public TeaCategory selectTeaCategoryById(Long id) {
        return teaCategoryMapper.selectTeaCategoryById(id);
    }

    /**
     * 查询产品大类列表
     *
     * @param teaCategory 产品大类
     * @return 产品大类
     */
    @Override
    public List<TeaCategory> selectTeaCategoryList(TeaCategory teaCategory) {
        return teaCategoryMapper.selectTeaCategoryList(teaCategory);
    }

    /**
     * 新增产品大类
     *
     * @param teaCategory 产品大类
     * @return 结果
     */
    @Override
    public int insertTeaCategory(TeaCategory teaCategory) {
        teaCategory.setCreateTime(DateUtils.getNowDate());
        return teaCategoryMapper.insertTeaCategory(teaCategory);
    }

    /**
     * 修改产品大类
     *
     * @param teaCategory 产品大类
     * @return 结果
     */
    @Override
    public int updateTeaCategory(TeaCategory teaCategory) {
        teaCategory.setUpdateTime(DateUtils.getNowDate());
        return teaCategoryMapper.updateTeaCategory(teaCategory);
    }

    /**
     * 批量删除产品大类
     *
     * @param ids 需要删除的产品大类主键
     * @return 结果
     */
    @Override
    public int deleteTeaCategoryByIds(Long[] ids) {
        return teaCategoryMapper.deleteTeaCategoryByIds(ids);
    }

    /**
     * 删除产品大类信息
     *
     * @param id 产品大类主键
     * @return 结果
     */
    @Override
    public int deleteTeaCategoryById(Long id) {
        return teaCategoryMapper.deleteTeaCategoryById(id);
    }

    @Override
    public List<TeaCategory> selectTeaCategoryListAll() {
        return teaCategoryMapper.selectTeaCategoryListAll();
    }

    @Override
    public TeaCategory selectTeaCategoryByName(String categoryName) {
        return teaCategoryMapper.selectTeaCategoryByName(categoryName);
    }
}
